from socket import *


# 处理具体的发请求和服务端通信的
class Handle:
    def __init__(self):
        # 服务器地址
        self.ARRD = ("127.0.0.1", 8888)
        # 创建套接字
        self.sock = self._connect()

    # 创建套接字并发起连接
    def _connect(self):
        sock = socket()
        sock.connect(self.ARRD)
        return sock

    def _login(self):
        self.sock.send(b"text")


# 和用户交互的事
class DICTView:
    def __init__(self):
        self.handle = Handle()

    def menu_2(self):
        while True:
            print("""
        =================查询界面==================
        1.>>查询单词<<  2.>>历史记录<<  3.>>注销<<
        ==========================================
        """)
            cmd = input("请输入选项:")
            if cmd == "1":
                pass
            elif cmd == "2":
                pass
            elif cmd == "3":
                break
            else:
                print("请输入正确的选项")

    def menu_1(self):
        while True:
            print("""
        +++++++++++++++++登录界面++++++++++++++++++
        1.>>登录<<  2.>>注册<<  3.>>退出<<
        ==========================================
        """)
            cmd = input("请输入选项:")
            if cmd == "1":
                # 调用具体方法
                self.handle._login()
                self.menu_2()
            elif cmd == "2":
                pass
            elif cmd == "3":
                break
            else:
                print("输入错误请重新输入正确选项!")

    def main(self):
        self.menu_1()


if __name__ == '__main__':
    dict = DICTView()
    dict.main()
